<?
/*
Edits / Revisions

12-28-10 changed io_cms.css location
	structural modifications

*/
if ($_SERVER['REQUEST_METHOD']=="POST") {	
	$xmlContent = $_POST['xmlContent'];
	// sanitize content for servers where magic_quotes_gdc is on
	$xmlContent = stripslashes($xmlContent);
	$xmlHeader = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
	$xmlFooter = "";
	global $xmlFile;
	writePHP($xmlHeader . $xmlContent . $xmlFooter, "newSpecs.xml");
	//include "meta.php";
}
else {
?>
<html>
	<head>
		<title>Indoor Outdoor &middot; Spec Sheet Writer</title>
	<link rel="stylesheet" type="text/css" href="admin/css/io_cms.css" />
	<script src="admin/js/jquery.1.4.min.js" type="text/javascript"></script>
	<script src="admin/js/io_library.js" type="text/javascript"></script>
	<script src="xml_actions.js" type="text/javascript"></script>
	</head>
	<body id="specsWriterBody">
	<div id="specsWriteContainer">
		<form action="write_xml.php" method="post">
		<div id="siteName" class="header">Site Name : <input class="inputField" type="text" name="sitename"></div>
		<input class="inputField" type="hidden" name="globalsStart">
		<div class="header">Global Variables</div>
		<div id="globalsContainer">
			<div class="globalVar">
			<span class="reqGlobal">Images_Path</span><input class="inputField" type="hidden" name="globalName" value="Images_Path"/>
			<input class="inputField" type="text" name="globalValue" value="assets/images/"/></div>	
			<div class="globalVar"><span class="reqGlobal">Thumbs_Path</span><input class="inputField" type="hidden" name="globalName" value="Thumbs_Path"/>
			<input class="inputField" type="text" name="globalValue" value="assets/images/thumbs/"/></div>	
			<div class="globalVar"><span class="reqGlobal">Audio_Path</span><input class="inputField" type="hidden" name="globalName" value="Audio_Path"/>
			<input class="inputField" type="text" name="globalValue" value="assets/audio/"/></div>	
			<div class="globalVar"><span class="reqGlobal">Movies_Path</span><input class="inputField" type="hidden" name="globalName" value="Movies_Path"/>
			<input class="inputField" type="text" name="globalValue" value="assets/video/"/></div>	
			<div class="globalVar"><span class="reqGlobal">Host</span><input class="inputField" type="hidden" name="globalName" value="host"/>
			<input class="inputField" type="text" name="globalValue" value="localhost"/></div>	
			<div class="globalVar"><span class="reqGlobal">Database</span><input class="inputField" type="hidden" name="globalName" value="database"/>
			<input class="inputField" type="text" name="globalValue" value="indoor"/></div>	
			<div class="globalVar"><span class="reqGlobal">Username</span><input class="inputField" type="hidden" name="globalName" value="username"/>
			<input class="inputField" type="text" name="globalValue" value="indoor"/></div>	
			<div class="globalVar"><span class="reqGlobal">Password</span><input class="inputField" type="hidden" name="globalName" value="password"/>
			<input class="inputField" type="text" name="globalValue" value="outdoor"/></div>	
			<div class="globalVar"><span class="reqGlobal">http_root</span><input class="inputField" type="hidden" name="globalName" value="http_root"/>
			<input class="inputField" type="text" name="globalValue" value="http://localhost:8888/sitename.com/"/></div>	
			<div class="globalVar"><span class="reqGlobal">server_root</span><input class="inputField" type="hidden" name="globalName" value="server_root"/>
			<input class="inputField" type="text" name="globalValue" value="/Applications/MAMP/htdocs/sitename.com/"/></div>	
			<div id="addGlobal" class="addButton">+ Global</span><input class="inputField" type="hidden" name="globalsEnd"></div>		
		</div> <!-- end globals container -->
		<div style="clear:both;">&nbsp;</div>
		<div id="newTable" class="addButton">+ Table</div>
		<input class="inputField" type="hidden" name="siteEnd">
		<input class="inputField specsBtn" type="submit" name="submitBtn" id="submitBtn" value="Build XML Sheet">
		</form>
	</div>
	<div id="linkToXML"></div>
	<div id="templates">
		<?php require_once('write_xml_templates.php'); ?>
	</div>
	</body>
</html>

<? }

function writePHP($output, $fileName) {
	global $xmlFile;
	$myfile = getcwd() . "/". $fileName;
	//echo "myfile = " . $myfile;
	echo "XML File:<br />\n<a href='". $fileName . "'>$fileName</a><br/><br /><div id='buildMetaBtn'>Build PHP Files</div>";
	$fh = fopen($myfile, 'w') or die("can't open file");
	fwrite($fh, $output);
	fclose($fh);
	$xmlFile = $fileName;
}

?>